import axios from '~/axios'

export function getImageList(categoryId, pageNumber= 1){
  const list = [
    { create_time: '', id: 301, image_class_id: 101, name: '1.jpg', path: 'public/sdfsdf.jpg',update_time: '', url: 'https://www.jzy.world/m/whiteaccount/1.jpg' },
    { create_time: '', id: 302, image_class_id: 101, name: '2.jpg', path: 'public/sdfsdf.jpg',update_time: '', url: 'https://www.jzy.world/m/whiteaccount/2.jpg' },
    { create_time: '', id: 303, image_class_id: 101, name: '3.jpg', path: 'public/sdfsdf.jpg',update_time: '', url: 'https://www.jzy.world/m/whiteaccount/3.jpg' },
    { create_time: '', id: 401, image_class_id: 102, name: '4.jpg', path: 'public/sdfsdf.jpg',update_time: '', url: 'https://www.jzy.world/m/whiteaccount/4.jpg' },
    { create_time: '', id: 401, image_class_id: 102, name: '5.jpg', path: 'public/sdfsdf.jpg',update_time: '', url: 'https://www.jzy.world/m/whiteaccount/5.jpg' },
    { create_time: '', id: 401, image_class_id: 102, name: '6.jpg', path: 'public/sdfsdf.jpg',update_time: '', url: 'https://www.jzy.world/m/whiteaccount/6.jpg' },
    { create_time: '', id: 501, image_class_id: 103, name: '7.jpg', path: 'public/sdfsdf.jpg',update_time: '', url: 'https://www.jzy.world/m/whiteaccount/7.jpg' },
    { create_time: '', id: 501, image_class_id: 103, name: '8.jpg', path: 'public/sdfsdf.jpg',update_time: '', url: 'https://www.jzy.world/m/whiteaccount/8.jpg' },
    { create_time: '', id: 501, image_class_id: 103, name: '9.jpg', path: 'public/sdfsdf.jpg',update_time: '', url: 'https://www.jzy.world/m/whiteaccount/9.jpg' },

  ]

  const targetList = list.filter(item => item.image_class_id === categoryId)
  const pageSize = 2
  const startIndex = (pageNumber - 1) * pageSize
  const endIndex = startIndex + pageSize;
  const pageData = targetList.slice(startIndex,endIndex)
  const resData = {list: pageData, pagination: {total: targetList.length}}
  const res = {code: 1, msg: '', data: resData}

  return new Promise((resolve, reject) => {
    resolve(res)
  })
}

// 传入 image 的主键 id，不实际删除后端数据
export function deleteImage(imgId){
  return new Promise((resolve, reject) => {
    resolve({code: 1,msg: '',data: null})
  })
}

export function updateImage(imgId, imgName){
  return new Promise((resolve, reject) => {
    resolve({code: 1, msg: `重命名：imgId:${imgId},imgName:${imgName}`, data: null})
  })
}

// 上传到顺杰项目
export const uploadUrl = '/shunjiebe/shipCustomsFiles/upload'
